//go:build !integration

package dropapp

import (
	"fmt"
	"testing"

	"v8s-api/rest-api/target/generated-sources"
)

type (
	suit struct {
		input    generated.TaskStatus
		expected StatusValue
	}
)

func TestConvertStatus(t *testing.T) {
	suits := []suit{
		{generated.TaskStatusCreationRequest, provisioningStatus},
		{generated.TaskStatusDeleted, deletedStatus},
		{generated.TaskStatusDeletionRequest, deletedStatus},
		{generated.TaskStatusError, errorStatus},
		{generated.TaskStatusResumeRequest, provisioningStatus},
		{generated.TaskStatusRunning, readyStatus},
		{generated.TaskStatusSuspended, pausedStatus},
		{generated.TaskStatusSuspensionRequest, pausedStatus},
		{generated.TaskStatusUpdateRequest, provisioningStatus},
	}

	for i, current := range suits {
		t.Run(fmt.Sprintf("Scenario %d", i), func(t *testing.T) {
			status, err := convertStatus(current.input)
			if err != nil {
				t.Fatalf("error: %s", err)
			}

			if status != current.expected {
				t.Errorf("expected '%s', but was '%s'", current.expected, status)
			}
		})
	}
}
